#ifndef SONYRESPONSIVEEXAMPLE_H
#define SONYRESPONSIVEEXAMPLE_H

#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QCheckBox>
#include <QSlider>
#include <QGroupBox>
#include "responsivefactory.h"
#include "sonyperformancemonitor.h"
#include "customfilebrowser.h"

/**
 * 🎨 SonyResponsiveExample - Sony Ive响应式系统使用示例
 *
 * 展示如何集成和使用响应式文件列表系统
 */

class SonyResponsiveExample : public QWidget
{
    Q_OBJECT

public:
    explicit SonyResponsiveExample(QWidget* parent = nullptr);
    ~SonyResponsiveExample() = default;

    // === 界面设置 ===
    void setupUI();
    void setupControlPanel();
    void setupFileBrowser();
    void setupPerformanceDisplay();

private slots:
    // === 控制面板槽 ===
    void onToggleResponsiveMode(bool enabled);
    void onToggleAnimations(bool enabled);
    void onTogglePerformanceMode(bool enabled);
    void onToggleAutoOptimization(bool enabled);
    void onAnimationDurationChanged(int value);
    void onHoverScaleChanged(int value);
    void onRunPerformanceTest();
    void onGenerateReport();

    // === 性能监控槽 ===
    void onPerformanceUpdate();
    void onPerformanceWarning(const QString& warning);
    void onOptimizationSuggested(const QString& suggestion);

    // === 浏览器事件 ===
    void onFileSelectionChanged(const QList<int>& selectedIndices);

private:
    // === UI组件 ===
    QVBoxLayout* m_mainLayout;
    QHBoxLayout* m_controlLayout;
    QVBoxLayout* m_browserLayout;
    QVBoxLayout* m_performanceLayout;

    // === 控制面板 ===
    QGroupBox* m_controlGroupBox;
    QCheckBox* m_responsiveModeCheckBox;
    QCheckBox* m_animationsCheckBox;
    QCheckBox* m_performanceModeCheckBox;
    QCheckBox* m_autoOptimizationCheckBox;
    QSlider* m_animationDurationSlider;
    QSlider* m_hoverScaleSlider;
    QLabel* m_animationDurationLabel;
    QLabel* m_hoverScaleLabel;
    QPushButton* m_performanceTestButton;
    QPushButton* m_generateReportButton;

    // === 文件浏览器 ===
    CustomFileBrowser* m_fileBrowser;
    QGroupBox* m_browserGroupBox;

    // === 性能显示 ===
    QGroupBox* m_performanceGroupBox;
    QLabel* m_fpsLabel;
    QLabel* m_memoryLabel;
    QLabel* m_cacheLabel;
    QLabel* m_warningsLabel;
    QTextEdit* m_performanceLog;

    // === 核心组件 ===
    ResponsiveFactory* m_factory;
    SonyPerformanceMonitor* m_performanceMonitor;

    // === 更新定时器 ===
    QTimer* m_updateTimer;

    // === 状态 ===
    bool m_responsiveModeEnabled;
    int m_currentFPS;
    int m_currentMemoryMB;
    int m_cacheHitRate;
    QStringList m_performanceWarnings;

    // === 常量 ===
    static constexpr int UPDATE_INTERVAL_MS = 500;      // 500ms更新间隔
    static constexpr int MIN_ANIMATION_DURATION = 50;   // 最小动画时长
    static constexpr int MAX_ANIMATION_DURATION = 1000;  // 最大动画时长
    static constexpr int MIN_HOVER_SCALE = 100;         // 最小悬停缩放(1.0x)
    static constexpr int MAX_HOVER_SCALE = 120;         // 最大悬停缩放(1.2x)
};

#endif // SONYRESPONSIVEEXAMPLE_H